﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

namespace WebService1
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod(Description="pegar dados dos usuarios")]
        public DataTable getUserData()
        {
            DataSet1TableAdapters.usuarioTableAdapter adapter = new DataSet1TableAdapters.usuarioTableAdapter();
            DataSet1.usuarioDataTable table = adapter.GetUsuarioData();
            
            return table;
        }

        [WebMethod]
        public List<Evento> get5Eventos(DateTime date, string username)
        {
            List<Evento> eventos = new List<Evento>();
            DataSet1TableAdapters.eventoTableAdapter adapter = new DataSet1TableAdapters.eventoTableAdapter();
            DataSet1.eventoDataTable table = adapter.GetEventoBy5(date, username);
            foreach (DataSet1.eventoRow r in table.Rows)
            {
                Evento ev = new Evento();
                
                ev.dataHora = Convert.ToDateTime(r["dataHora"].ToString());
                ev.descricao = r["descricao"].ToString();
                ev.id = Convert.ToInt32(r["id"]);
                ev.nome = r["nome"].ToString();
                ev.situacao = Convert.ToInt32(r["situacao"]);

                eventos.Add(ev);
            }

            return eventos;
        }
    }
}